package com.example.controller;

import com.example.entity.specification_option;
import com.example.util.PageResult;
import com.example.util.R;
import com.example.vo.specification_optionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.service.specification_optionService;
import java.util.List;

@RestController
@RequestMapping("/specification_option")
 @CrossOrigin            // 解决跨域问题
public class Specification_optionController {

    @Autowired
    private specification_optionService tbSpecificationOptionService;
    @PostMapping("/search")
    public PageResult<specification_option> search(@RequestParam("page") Integer page,
                                                   @RequestParam("pageSize") Integer pageSize,
                                                   @RequestBody(required = false)specification_optionVO tbSpecificationOptionVo){
        return tbSpecificationOptionService.search(page,pageSize,tbSpecificationOptionVo);
    }

    // 4. 保存规格
    @PostMapping("/save")
    public R save(@RequestBody specification_option tbSpecificationOption){
        return tbSpecificationOptionService.save(tbSpecificationOption) ? R.ok().message("规格选项添加成功！") : R.error().message("规格选项添加失败！");
    }
}
